﻿using System;
using System.Web.UI;

namespace UDS.SubModule.UnitiveDocument.DocumentFlowPages
{
    /// <summary>
    /// PostilDocument 的摘要说明。
    /// </summary>
    public partial class PostilDocumentPage : Page
    {
        private long DocID;
        private int Operation;
        private string UserName;

        protected override void OnInit(EventArgs e)
        {
            cmdOK.Click += cmdOK_Click;
            base.OnInit(e);
        }

        protected override void OnLoad(EventArgs e)
        {
            //cmdCancel.Attributes.Add("onclick","javascript:window.close();");
            DocID = Int32.Parse(Request["DocID"]);
            Operation = Int32.Parse(Request["Operation"]);
            UserName = SiteContext.Current.UserName;
            switch (Operation)
            {
                case 1:
                    labTitle.Text = "通过批注:";
                    break;
                case 2:
                    labTitle.Text = "失败批注:";
                    break;
                case 3:
                    labTitle.Text = "完成批注:";
                    break;
                default:
                    break;
            }

            base.OnLoad(e);
        }

        private void cmdOK_Click(object sender, EventArgs e)
        {
            throw new NotImplementedException("Finish the code below");
            // var df = new DocumentFlow();

            // TODO:
            // Finish the code below.

            //df.AddPostil(UserName,DocID,txtPostil.Text,Operation);

            //switch(Operation)
            //{
            //    case 1:
            //        NextDocument(DocID);
            //        break;
            //    case 2:
            //        df.FaileDocument(DocID);					
            //        break;
            //    case 3:
            //        df.FinishDocument(DocID);					
            //        break;
            //    default:
            //        break;
            //}

            //df = null;
            //Server.Transfer("ListDocument.aspx?DisplayType=3");

            //Response.Write("<script laguage='javascript'>window.close();</script>");
        }

        private void NextDocument(long lDocID)
        {
            throw new NotImplementedException("Finish the code below");
            //long DefineID;

            //var df = new DocumentFlow();

            // TODO:
            // Finish the code below.

            //DefineID = df.GetNextDefineID(lDocID);							

            //if(DefineID>0)
            //{
            //    //发送到下一环节
            //    switch(df.GetTacheRule(DefineID))
            //    {					
            //        case 0:													//按项目走	
            //            if(df.GetParentProjectAccount(UserName)>0)			//有上级项目
            //            {	
            //                df = null;
            //                Server.Transfer("SelectProject.aspx?DocID=" + lDocID.ToString() + "&DefineID=" + DefineID.ToString());							
            //            }
            //            else												//没有上级项目
            //            {										
            //                Response.Write("<script language='javascript'>alert('" + df.DoMessage(-3,lDocID) + "');</script>");
            //                df = null;
            //            }
            //            break;					
            //        case 1:													//按部门走		
            //            Response.Write("<script language='javascript'>alert('" + df.DoMessage(df.PostDocument(UserName,DocID,DefineID,0),DocID) + "');</script>");
            //            break;					
            //        case 2:													//其他：环节全部的人都走
            //            break;
            //        default:
            //            break;
            //    }
            //}
            //else
            //    df.FinishDocument(lDocID);									//没有下一环节，结束

            //df = null;
        }
    }
}